<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: PortalPageRecord.php 385 2010-12-22 14:04:00Z steen.rabol $
 */

Prado::using('Application.Common.Data.PortalActiveRecord');
Prado::using('Application.Common.Data.PortalUserRecord');

class PortalPageRecord extends PortalActiveRecord
{
	const TABLE				= 'tblpages';

	public $id;
	public $name;
	public $role			= 0;
	public $active			= 1;
	public $created;
	public $modified;
	public $locked 			= 0;
	public $displayname;
	public $layoutname;
	public $displayorder	= 999;
	public $lockedby		= 0;
	public $lockedtime		= 0;
	public $createdby;
	public $path;
	public $fullpath;
	public $metakeywords	= '';
	public $metadescription	= '';
	public $expire			= 0;
	public $culture			= 'en';
	private $_userrecord	= null;

	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}

	public function getCreatedByName()
	{
		if($this->_userrecord === null)
		{
			$this->_userrecord	= PortalUserRecord::finder()->findByid($this->createdby);
		}

		return $this->_userrecord->full_name;
	}

	public static function PageExists($id)
	{
		$res	= $this->DbConnection->createCommand($sql)->queryScalar();
		return $res == $id;
	}

	public static function getPageFromId($id)
	{
		return $this->DbConnection->createCommand("select page from tblpages where id=$id")->queryScalar();
	}
}
?>